<%@ page contentType="text/html; charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head>
<link href="${ctx}/css/main/base.css" rel="stylesheet" type="text/css"/>
<link href="${ctx}/css/main/main.css" rel="stylesheet" type="text/css"/>

<body class="m_6" style="over" onload="errInfo();">
<form name="addF" method="post">
<input type="hidden" name="info" id="info" value="${info}"/>
<div id="main">
	<div class="zdsz" id="select1">
		<div class="tab"><h3  onclick="f1();">管理资源</h3><h3  onclick="f2();">新建资源</h3><h3 class="sel" onclick="f3();">设置禁用资源</h3><h3 id="err"></h3> </div>
		
	</div>
</div>
</form>
</body>
</html>
<script type="text/javascript">
	function createAsset(){
		var fettle=1;
		if(!ValidateText("funcName")){
			fettle=0;
			alert("功能点不能为空！");
		}else if(!ValidateText("assetOrder")){
			fettle=0;
			alert("资源排序号不能为空！");
		}else if(!ValidatePhone("assetOrder")){
			fettle=0;
			alert("资源排序号只能是数字！");
		}else if(!Limit("assetOrder",3)){
			fettle=0;
			alert("资源排序号长度不能超过2！");
		}else if(!ValidateText("assetName")){
			fettle=0;
			alert("资源名称不能为空！");
		}else if(!Limit("assetName",51)){
			fettle=0;
			alert("资源名称长度不能超过50！");
		}else if(!ValidateText("assetNameEn")){
			fettle=0;
			alert("资源英文名称不能为空！");
		}else if(!Limit("assetNameEn",51)){
			fettle=0;
			alert("资源英文名称长度不能超过50！");
		}else if(!ValidateText("assetLink")){
			fettle=0;
			alert("资源连接不能为空！");
		}else if(!Limit("assetLink",256)){
			fettle=0;
			alert("资源链接长度不能超过255！");
		}
	if(fettle==1){
		document.forms[0].action = "${ctx}/asset/asset!createSysAsset.action";
		document.forms[0].submit();
	}
	}
	
	function f1(){
		parent.location = "${ctx}/asset/asset!index.action";
	}
	function f2(){
		parent.location = "${ctx}/asset/asset!preCreateSysAsset.action";
	}
	function f3(){
		parent.location = "${ctx}/asset/asset!preSetAssetIdGroup.action";
	}
	
	
	//文本框输入是否过长
function Limit(txt_id,count){
  var txt=document.getElementById(txt_id);
  if(txt.value.length>count-1){
    txt.value=txt.value.substr(0,count);
    return false;
  }
  else{
    return true;
  }
}
	
	
	//文本框是否为空
function ValidateText(text_id){
  var txtName=document.getElementById(text_id);
  if(txtName.value==""){
    txtName.focus();
    return false;
  }
  else{
    return true;
  }
}

//是否是数字(适用于电话验证)
function ValidatePhone(num_id){
	var num_id=document.getElementById(num_id);
	var num_str=num_id.value.toString();
	var i;
	var fettle=1;
	var text_arr=new Array(num_str.length);
	for(i=0;i<num_str.length;i++){
		text_arr[i]=num_str.substr(i,1);
	}
	for(i=0;i<num_str.length;i++){
		if(isNaN(text_arr[i])&&text_arr[i]!="-"){
			fettle=0;
			break;
		}	
	}
	if(fettle==1){
		return true;	
	}
	else if(fettle==0){
		return false;	
	}
}

function errInfo(){
	
		var info = document.getElementById("info").value;
		
		if(info == 'asset_1'){
		   document.getElementById("err").innerHTML ="<font color='red'>成功!</div>";
		   
		}else if(info == 'asset_2'){
			document.getElementById("err").innerHTML ="<font color='red'>请选择功能点!</div>";
		}else if(info == 'asset_3'){
			document.getElementById("err").innerHTML ="<font color='red'>资源名称不能为空!</div>";
		}else if(info == 'asset_4'){
			document.getElementById("err").innerHTML ="<font color='red'>资源英文名称不能为空!</div>";
		}else if(info == 'asset_5'){
			document.getElementById("err").innerHTML ="<font color='red'>资源链接不能为空!</div>";
		}else if(info == 'asset_0'){
			document.getElementById("err").innerHTML ="<font color='red'>失败!</div>";
		}
	}
	
	
	
function chooseFuncs(id,name){
	var names ="";
    var ids ="";
	var item=window.showModalDialog("${ctx}/asset/asset!chooseFunc.action?time="+new Date().getTime(),window,"scroll:yes;dialogHeight=420px;dialogWidth=420px;");
    if(item != null){
     names = item[1];
     ids = item[0];
   	 document.getElementById(id).value = ids;
   	 document.getElementById(name).value = names;
	}
}
</script>
